package com.macro.mall.common.constants;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Objects;

public class Constants {

    public enum ActivitiesTypeEnum {

        TOURISM("tourism", "0"),
        MUSEUM("museum", "1"),
        NARRATOR("narrator", "2"),
        EMPTY();

        private String code;

        private String type;

        ActivitiesTypeEnum() {
        }

        ActivitiesTypeEnum(String code, String type) {
            this.code = code;
            this.type = type;
        }

        public static String getActivitiesSnapshot(String type, String activitiesId, LocalDateTime applicationTime) {
            ActivitiesTypeEnum activitiesTypeEnum = Arrays.stream(ActivitiesTypeEnum.values()).filter(i -> i.type.equals(type)).findFirst().orElse(null);
            if (Objects.nonNull(activitiesTypeEnum)) {
                return activitiesTypeEnum.code + "_" + activitiesId + "_" + applicationTime.toLocalDate().toString();
            }
            return null;
        }
    }


    public enum ActivitiesResultEnum {

        SNAPSHOT_NULL_ERROR("500", "未查询到详细库存信息"),
        TICKETS_REMAIN("500", "余票不足"),
        RESET_TICKETS_ERROR("500", "库存恢复失败"),
        BASE_INFO_ERROR("500", "您已报名，请勿重复报名"),
        APPLICANT_SUCCESS("200", "预约成功"),
        RESET_APPLICANT_SUCCESS("200", "取消预约成功"),
        APPLICANT_ERROR("500", "预约失败"),
        RESET_APPLICANT_ERROR("500", "取消预约失败");

        private String code;

        private String message;


        ActivitiesResultEnum() {
        }

        ActivitiesResultEnum(String code, String message) {
            this.code = code;
            this.message = message;
        }

        public String getMessage() {
            return message;
        }

        public String getCode() {
            return code;
        }
    }
}
